<?php
/**
* @package Postman
* @copyright Авторские права (C) 2009 www.yar-it.com. Все права защищены.
* @license Лицензия http://www.gnu.org/licenses/gpl-2.0.htm GNU/GPL, или help/license.php
* Postman! - свободное программное обеспечение распространяемое по условиям лицензии GNU/GPL
* Для получения информации о используемых расширениях и замечаний об авторском праве, смотрите файл copyright.php.
*/
defined( '_VALID_MOS' ) or die( '' );
function update( $action, $task ) {
	$update = new wupdate();
	$showListing = true;
	$showComplete = false;

	 $message = mosGetParam($_REQUEST, 'message', '');

	 if (ini_get('safe_mode')) {

	 } else {
	 	 @set_time_limit(60 * $GLOBALS[ACA.'script_timeout']);
	 }


	 switch ($task) {
		 case ('doUpdate') :
			backHTML::_header( _ACA_MENU_UPDATE , 'update' , $message  , $task, $action );
			$update->doUpdate();
	     	$showListing = false;
	     	$showComplete = false;
	     	break;
		 case ('version') :
			$update->getVersion();
			break;
		 case ('complete') :
			$showComplete = true;
	     	$showListing = false;
			break;
		 case ('cancel') :
		 	compa::redirect('index2.php?option=com_postman&act=update');
	     	$showListing = false;
			break;
      	case ('cpanel'):
		 	compa::redirect('index2.php?option=com_postman');
	     	$showListing = false;
        	break;
      	case ('new1'):
	 		backHTML::_header( _ACA_MENU_UPDATE , 'backup.png' , $message , $task, $action  );
      		$message = postman::printYN( postman::upgrade_News1() ,  '<br />' ._ACA_IMPORT_SUCCESS.' Anjel data' , _ACA_ERROR );
	   		postman::resetUpgrade(1);
	   		echo '<br />'.$message;
        	break;
      	case ('new2'):
	 		backHTML::_header( _ACA_MENU_UPDATE , 'backup.png' , $message , $task, $action  );
      		$message = postman::printYN( postman::upgrade_News2() ,  '<br />' ._ACA_IMPORT_SUCCESS.' Letterman data' , _ACA_ERROR );
	     	postman::resetUpgrade(2);
	   		echo '<br />'.$message;
        	break;
      	case ('new3'):
	 		backHTML::_header( _ACA_MENU_UPDATE , 'backup.png' , $message , $task, $action  );
      		$message = postman::printYN( postman::upgrade_News3() ,  '<br />' ._ACA_IMPORT_SUCCESS.' YaNC data' , _ACA_ERROR );
	     	postman::resetUpgrade(3);
	   		echo '<br />'.$message;
        	break;
	 }

	 if ($showListing) {
		backHTML::_header( _ACA_MENU_UPDATE , 'backup.png' , $message , $task, $action  );
 		backHTML::_upgrade();
 		$forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n" ;
		echo $forms['main'];
		backHTML::formStart('' , ''  ,'' );
		backHTML::showCompsList($update);
		$go[] = postman::makeObj('act', $action);
		backHTML::formEnd($go);
	 } elseif ($showComplete) {
		backHTML::_header( _ACA_MENU_UPDATE , 'backup.png' , $message , $task, $action  );
 		$forms['main'] = " <form action='index2.php' method='post' name='adminForm'> \n" ;
		echo $forms['main'];
		backHTML::formStart('' , ''  ,'' );
		backHTML::showUpdateOptions($update);
		$go[] = postman::makeObj('act', $action);
		backHTML::formEnd($go);
	 }
 }

